package com.yidu.StockControl.mapper;

import com.yidu.StockControl.entity.CashInventory;
import com.yidu.StockControl.entity.CashInventorys;
import com.yidu.StockControl.entity.SecurityInventors;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 现金库存     现金库存        现金库存        现金库存
 */
@Repository
public interface CashInventorysMapper {
    /*
     查询
    */

    @Select("select * from cashInventorys WHERE 1=1 ${strWhere} LIMIT #{page},#{limit}")
    public List<CashInventorys> selectCashInventorys(Map map);

    @Select("select count(*) from cashInventorys")
    int selectCashInventorysCount();
    /*
     插入
     */
    @Insert("insert into cashInventorys values(#{cashInventorysId},#{fundId},#{cashInventorysTime},#{cashId},#{accounName},#{balance})")
    public int insertCashInventorys(CashInventorys cashInventorys);
    /*
     修改
     */
    @Update("update cashInventorys set fundId=#{fundId},cashInventorysTime=#{cashInventorysTime},cashId=#{cashId},accounName=#{accounName},balance=#{balance} " +
            "where cashInventorysId=#{cashInventorysId}")
    public void updateCashInventorys(CashInventorys cashInventorys);
    /*
    删除
     */
    @Delete("delete FROM cashInventorys where cashInventorysId = #{cashInventorysId}")
    public  void  deleteCashInventorys(String cashInventorysId);

    @Delete("delete FROM cashInventorys where cashInventorysId =#{cashInventorysId} and fundId = #{fundId} and cashInventorysTime=DATE_FORMAT(DATE_ADD(STR_TO_DATE(#{dateTime},'%Y-%m-%d'),INTERVAL -1 DAY),'%Y-%m-%d')")
    public int deleteCashInventorysDate(String cashInventorysId, String fundId, String dateTime);


}
